import { fetchApiWithGet, fetchApiWithPost } from '../utils/index'
import { FETCH_SORTS_SUCC, FETCH_SORTS_FAIL, FETCH_GOODS_FROM_SORT_SUCC, FETCH_GOODS_FROM_SORT_FAIL } from '../contants/sort'

const publicUrl = 'http://fengke.net:8081/shop/';

export function fetchSort(storeId) {
	var url = `${publicUrl}class_display`;
	var argus = {
		storeId: storeId
	};
	return dispatch => {
		fetchApiWithPost(url, argus, dispatch, FETCH_SORTS_SUCC, FETCH_SORTS_SUCC)
	}
	
}

export function fetchGoodsFromData(classId) {
	var url = `${publicUrl}goodsByClass_display?classId=${classId}&num=20`;
	return dispatch => {
		fetchApiWithGet(url, dispatch, FETCH_GOODS_FROM_SORT_SUCC, FETCH_GOODS_FROM_SORT_FAIL)
	}
	
}